package com.microblogforsim.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.microblogforsim.R;
import com.microblogforsim.model.Index_Post;

import java.util.ArrayList;

public class Index_List_Adapter extends BaseAdapter {
    private Context context;
    private ArrayList<Index_Post> posts;

    public Index_List_Adapter(Context context) {
        this.context = context;
    }

    public void replayAll(ArrayList<Index_Post> data){
        if (posts == null) posts = new ArrayList<>();
        posts.addAll(data);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return posts.size();
    }

    @Override
    public Object getItem(int position) {
        return posts.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.index_list_item,null);
        return convertView;
    }
}
